194
Chapter 9 Juggling Logs and Other Circus Tricks
Visualizing Data Through RRDtool
So, we’re collecting metrics, but this doesn’t help us solve our problem.We must be able
to visualize it for it to prove useful. Like everything else with RRDtool, the visualization
can do exactly what you want, but the user interface to do it is 100% engineer and 0%
designer.We have a web wrapper around most of the RRD graphs we can generate,
which makes them quite nice; but I’ll show you the “under the hood” graph generation
here so that you can have a healthy respect for why someone should wrap it with a sim-
ple web interface.
To generate a graph that is ugly, we can call rrdtool in its simple form:
rrdtool graph \
ugly.png –title "web traffic" -a PNG \
--vertical-label "bits/sec" –width 800 –height 500 \
"DEF:inbytes=/var/rrds/web-inbytes.rrd:inbytes:AVERAGE" \
"DEF:outbytes=/var/rrds/web-outbytes.rrd:inbytes:AVERAGE" \
"CDEF:realinbits=inbytes,8,*" \
"CDEF:realoutbits=outbytes,8,*" \
"AREA:realinbits#0000ff:Inbound Traffic" \
"LINE1:realoutbits#ff0000:Outbound Traffic" \
--start -172800
Yes, that’s the simple form. It pulls the in and out byte metrics over the last 172,800 sec-
onds (two days) from their respective RRD files, multiplies them by 8 (to get bits), and
graphs the inbound in a blue area curve and the outbound in a red line curve.
It produces something usable, but so ugly I refuse to grace this book with it. So, we
will consult a visualization expert and show the traffic sent to the Internet on the posi-
tive y-axis and the traffic received from the Internet on the negative y-axis (the total hits
being the area in between).Additionally, we will add some gradient pizzazz and end up
with the following (utterly obtuse) command that produces Figure 9.5:
rrdtool graph webtraffic.png –title "web traffic" -a PNG
--vertical-label "bits / sec"
--width 450 --height 180
DEF:outbytes=/var/rrds/web-outbytes.rrd:outbytes:AVERAGE
DEF:inbytes=/var/rrds/web-inbytes.rrd:inbytes:AVERAGE
"CDEF:realout=outbytes,8,*,-1,*" \
"CDEF:realin=inbytes,8,*" \
"CDEF:realout1=outbytes,8,*,-1,*,3,*,4,/" \
"CDEF:realout_h=outbytes,8,*" \
"CDEF:realout2=outbytes,8,*,-1,*,2,*,4,/" \
"CDEF:realin3=inbytes,8,*,1,*,4,/" \
"CDEF:realoutb=outbytes,8,*,-1,*" \
"CDEF:realinb=inbytes,8,*" \
"CDEF:realin_h=inbytes,8,*" \
"CDEF:realin1=inbytes,8,*,3,*,4,/" \
"CDEF:realin2=inbytes,8,*,2,*,4,/" \
"CDEF:realout3=outbytes,8,*,-1,*,1,*,4,/" \